package com.baoer.controller;

import com.baoer.R;
import com.baoer.entity.Shift;
import com.baoer.entity.Trip;
import com.baoer.entity.Triptype;
import com.baoer.service.TripService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Slf4j
public class TripController {

    @Autowired
    private TripService tripService;

    //查询旅行信息列表
    @PostMapping("/getTripList")
    public R getTripList(@RequestBody Map<String, Object> map){
        return R.ok(tripService.getTripList(map));
    }
    //添加旅行信息
    @PostMapping("/addtrip")
    public R addTrip(@RequestBody Trip trip){
        return tripService.addtrip(trip);
    }


    //修改旅行信息
    @PostMapping("/updatetrip")
    public R updateTrip(@RequestBody Trip trip){
        return tripService.updatetrip(trip);
    }
    //删除旅行信息
    @PostMapping("/deltrip")
    public R delTrip(@RequestBody Trip trip){
        return R.ok(tripService.deltrip(trip.getTripId()));
    }
    //查询旅行信息详情
    @PostMapping("/tripinfo")
    public R tripinfo(@RequestBody Trip trip){
        return R.ok(tripService.tripinfo(trip.getTripId()));
    }
    //查看班次
    @PostMapping("/shiftlist")
    public R shiftlist(@RequestBody Trip trip){
        return R.ok(tripService.shiftlist(trip.getTripId()));
    }
    //添加班次
    @PostMapping("/addshift")
    public R addShift(@RequestBody Shift shift){
        return R.ok(tripService.addshift(shift));
    }
    //查询旅行类型列表
    @PostMapping("/triptypelist")
    public R triptypelist(@RequestBody Map<String, Object> map){
//        int pageIndex = (int) map.get("pageIndex");
//        int pageSize = (int) map.get("pageSize");
        return R.ok(tripService.triptypelist(map));
    }
    //添加旅行类型
    @PostMapping("/addtriptype")
    public R addTriptype(@RequestBody Triptype triptype){
        return R.ok(tripService.addtriptype(triptype));
    }
}
